Skip to content

[codex] Attribute app-server analytics by thread originator#29935

Merged
alexsong-oai merged 1 commit into
mainfrom
codex/thread-originator-analytics
Jun 26, 2026
Merged

[codex] Attribute app-server analytics by thread originator#29935
alexsong-oai merged 1 commit into
mainfrom
codex/thread-originator-analytics

Conversation

@alexsong-oai

Copy link
Copy Markdown
Collaborator

Why

Desktop Work threads and regular Codex threads can share the same app-server connection. App-server analytics currently copy product_client_id from connection metadata for every thread-scoped event, so Work thread activity is attributed to the Desktop connection instead of the thread's resolved originator. This prevents analytics from distinguishing the two products on a shared connection.

What changed

  • Publish the resolved originator after a thread is materialized, covering new, resumed, forked, and subagent threads.
  • Store that originator in the analytics reducer's existing per-thread state.
  • Override only app_server_client.product_client_id for thread, turn, tool, review, goal, guardian, and compaction events while preserving the connection's client name, version, and transport metadata.
  • Fall back to the connection-wide product client ID when a thread has no originator override.
  • Preserve persisted originators in thread initialization analytics for resume and fork flows.

Validation

  • just test -p codex-analytics thread_originator_overrides_shared_connection_across_thread_events subagent_events_keep_thread_originator_with_explicit_turn_connection
  • just test -p codex-app-server turn_start_tracks_thread_originator_in_analytics thread_start_tracks_thread_initialized_analytics thread_fork_tracks_thread_initialized_analytics thread_resume_tracks_thread_initialized_analytics
  • just test -p codex-core thread_manager

@alexsong-oai alexsong-oai requested a review from a team as a code owner June 25, 2026 00:40
@alexsong-oai

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 1f4391a50c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/analytics/src/client.rs Outdated
}

pub fn set_thread_originator(&self, thread_id: String, originator: String) {
self.record_fact(AnalyticsFact::SetThreadOriginator {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be a best-effort fact. If this drops but a later thread response gets through, we silently use the connection product ID for the rest of the thread. Can we carry the originator with the lifecycle fact or otherwise publish this state losslessly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, carried the originator on the ClientResponse lifecycle fact itself,

event,
&thread.id,
&thread.session_id,
"codex",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not exercise the override: the persisted originator and connection product ID are both "codex", so it passes if SetThreadOriginator is never sent

@alexsong-oai alexsong-oai force-pushed the codex/thread-originator-analytics branch 3 times, most recently from 7b8b135 to f0d2065 Compare June 25, 2026 22:36

@jif-oai jif-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approving

Comment thread codex-rs/app-server/src/request_processors/thread_processor.rs
@alexsong-oai alexsong-oai force-pushed the codex/thread-originator-analytics branch from f0d2065 to 69af693 Compare June 25, 2026 23:59
@alexsong-oai alexsong-oai force-pushed the codex/thread-originator-analytics branch from 69af693 to 192b2a8 Compare June 26, 2026 00:36
@alexsong-oai alexsong-oai merged commit 841f305 into main Jun 26, 2026
45 of 47 checks passed
@alexsong-oai alexsong-oai deleted the codex/thread-originator-analytics branch June 26, 2026 01:15
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants